<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="classes/CommonHelper.class.jsp" %>
<%@ include file="classes/DBHelper.class.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    request.setCharacterEncoding("UTF-8");
    String keyword = request.getParameter("keyword") == null ? "" : request.getParameter("keyword");
    String sql = "select * from wlxj_consult t where 1=1 ";
    List<Object> params = new ArrayList<Object>();
    if (!keyword.equals("")) {
        sql += " and (t.messager_name like ?";
        params.add("%" + keyword + "%");
        sql += " or t.title like ?";
        params.add("%" + keyword + "%");
        sql += " or t.content like ?)";
        params.add("%" + keyword + "%");
    }

    sql += " order by t.submit_time desc";

    int currentPage = 1;
    if (!nullOrEmpty(getParameter(request, "currentPage"))) {
        currentPage = Integer.parseInt(getParameter(request, "currentPage"));
    }

    List<Map<String, Object>> list = queryForListPage(sql, params, currentPage, 15);

    int total = queryForPageCount(sql, params);

    Map<String, Integer> pageMap = new HashMap<String, Integer>();
    pageMap.put("currentPage", currentPage);
    pageMap.put("total", total);
    request.setAttribute("page", pageMap);


%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>网络信件</title>
        <script type="text/javascript" src="js/jquery-1.8.0.js"></script>
        <link rel="stylesheet" href="css/tablecloth.css"  />
        <style type="text/css">
        </style>
    </head>
    <body style="padding: 0px; margin: 0px; font-size: 12px;">
        <form name="myform" action="wlxj_gl_list.jsp?r=<%=new Date().getTime()%>" method="post">
            <table>
                <tr>
                    <td> 关键字：<input type="text" name="keyword" value="<%=keyword%>"/> </td>
                    <td> <input type="submit" value="查询"/> </td>
                </tr>
            </table>
            <table id="mytable" style="width: 100%">
                <tr>
                    <th width="160">写信人名）</th>
                    <th>标题</th>
                    <th width="120">写信时间</th>
                    <th width="120">办理状态</th>
                    <th width="100">查看详细</th>
                </tr>
                <c:forEach items="<%=list%>" var="info">
                    <tr>
                        <td>${info.messager_name }</td>
                        <td>${info.title }</td>
                        <td>
                            <c:if test="${null!=info.submit_time }">
                                <fmt:formatDate value="${info.submit_time }" pattern="yyyy-MM-dd"/>
                            </c:if>	
                        </td>
                        <td>
                            <c:if test="${info.status==1 }">未办理</c:if>
                            <c:if test="${info.status==2 }">办理中</c:if>
                            <c:if test="${info.status==3 }">已办理</c:if>
                            </td>
                            <td>
                                [<a href="wlxj_gl_detail.jsp?message_id=${info.message_id }&r=<%=new Date().getTime()%>">详情</a>]	
                        </td>
                    </tr>
                </c:forEach>
                <tr>
                    <td colspan="5">
                        <jsp:include page="/common/page.jsp" >
                            <jsp:param value="${page.currentPage }" name="currentPage"/>
                            <jsp:param value="${page.total }" name="totalRecord"/>
                            <jsp:param value="15" name="pageSize"/>
                            <jsp:param value="myform" name="formName"/>
                            <jsp:param value="<%=new Date().getTime()%>" name="r"/>
                        </jsp:include>
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>
